<template>
	<z-paging ref="paging" v-model="dataList" @query="queryList"
		:loading-more-custom-style="{ paddingBottom: 'env(safe-area-inset-bottom)' }">
		<template #top>
			<view class="zpagin_top">
				<nav-bar :iconLeft="true" />
				<view class="search">
					<custom-search v-model="queryParams.search" @search="refreshList" placeholder="请输入生产单号/计划号/客户名称" />
				</view>
			</view>
		</template>
		<uni-card v-for="item in dataList" :key="item.id" margin="10px" spacing="0">
			<template v-slot:title>
				<uni-list>
					<uni-list-item :title="item.code" thumbSize="lg">
						<template v-slot:footer>
							<up-tag size="mini" :text="status_list[item.status_display].text" plain plainFill
								:type="status_list[item.status_display].type" />
						</template>
					</uni-list-item>
				</uni-list>
			</template>
			<view class="ctent">客户名称：{{ item.client_name }}</view>
			<view class="ctent">交货日期：{{ item.delivery_date }}</view>
			<view class="ctent">预计完成日期：{{ item.finish_date }}</view>
			<view class="ctent">生产数量：{{ item.all_num }}</view>
			<view class="con">
				<view class="ctent ">应领料数：{{ item.all_f_num }}</view>
				<view class="ctent ">已领料数：{{ item.total_up_num }}</view>
			</view>
			<view class="con">
				<view class="ctent">已完成数：{{ item.total_finish_num }}</view>
				<view class="ctent">已入库数：{{ item.total_in_num }}</view>
			</view>
			<view class="con">
				<view class="ctent">不良品数：{{ item.total_flaw_num }}</view>
				<view class="ctent">报废品数：{{ item.total_waste_num }}</view>
			</view>
			<view class="con">
				<view class="con_button" v-if="$hasPerm(['70501'])" @click.stop="register(item.id)" style="margin-left: auto;">
					登记
				</view>
			</view>
		</uni-card>
	</z-paging>
</template>
<script setup>
import { reactive, ref, } from 'vue';
import pOrderApi from '../../../api/production/p_order'

uni.$bus.useBusOn('p_register:refresh', refreshList)

const status_list = {
	'已审核': { text: '已审核', type: 'success' },
}
//数据请求
const paging = ref(null);
const dataList = ref([]);
const queryParams = reactive({
	search: '',
})
function queryList(pageNo, pageSize) {
	const params = {
		page: pageNo,
		page_size: pageSize,
		status: 2,
		...queryParams
	}
	pOrderApi.get_production_order(params).then((res) => {
		paging.value.complete(res.results);
	})
}

const pageUrl = '/views/production/p_register'

function register(id) {
	uni.navigateTo({
		url: `${pageUrl}/compile?id=${id}`
	})
}
//编辑跳转刷新
function refreshList() {
	paging.value.reload();
}



</script>

<style lang="scss"></style>